/**
 * Copyright (c) Software Institute of PKU
 * All rights reserved. 
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 */
package edu.pku.sei.modeler.editparts;

import java.beans.PropertyChangeEvent;

import org.eclipse.swt.graphics.Image;

import edu.pku.sei.modeler.edit.parts.BaseTreeEditPart;
import edu.pku.sei.modeler.images.ImageProvider;
import edu.pku.sei.modeler.model.core.CorePackage;
import edu.pku.sei.modeler.model.core.MetaComment;
import edu.pku.sei.modeler.model.structure.MetaShapeElement;

/**
 * @author xy
 *
 */
public class MetaCommentTreeEditPart extends BaseTreeEditPart{
    public MetaCommentTreeEditPart(MetaShapeElement model) {
        super(model);
    }

    protected void handlePropertyChanged(PropertyChangeEvent event) {
    	String propertyName = event.getPropertyName();
		if(propertyName.equals(CorePackage.COMMENT_BODY)) {
			refreshVisuals();
		}
	}

    protected void refreshVisuals() {
    	MetaComment comment = (MetaComment)((MetaShapeElement)getModel()).getModelElement();
    	String body = comment.getBody();
    	Image image = ImageProvider.getImage(ImageProvider.COMMENT_IMAGE);
    	setWidgetImage(image);
        setWidgetText(body);
    }
}